#pragma once
#include "RBTree.h"

template<class K>
class set
{
	struct setkeyofT
	{
		const K& operator()(const K& key)
		{
			return key;
		}
	};
public:
	typedef typename RBTree<K, K, setkeyofT>::iterator iterator;
	typedef typename RBTree<K, K, setkeyofT>::const_iterator const_iterator;
	iterator begin()
	{
		return _t.begin();
	}
	iterator end()
	{
		return _t.end();
	}

	const_iterator cbegin()
	{
		return _t.cbegin();
	}
	const_iterator cend()
	{
		return _t.cend();
	}

	iterator Insert(const K& key)
	{
		return _t.Insert(key).first;
	}

	iterator find(const K& key)
	{
		return _t.find(key);
	}
private:
	RBTree<K, K, setkeyofT> _t;
};

void test_set1()
{
	set<int> s;
	int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto e : a)
	{
		s.Insert(e);
	}

	set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		//if(*it % 2 == 0)
		//	*it += 100;

		cout << *it << " ";
		++it;
	}
	cout << endl;
}